package com.codingfuture.web.controller;

import com.codingfuture.entity.User;
import com.codingfuture.service.UserService;
import com.codingfuture.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {

    // 依赖注入
    @Autowired
    private UserService userService;

    // 登录方法
    @ResponseBody
    @RequestMapping("/login")
    public Result login(@RequestBody User user) {
        boolean rs = userService.login(user);
        return rs ? Result.ok(rs) : Result.err();
    }
}
